home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
utilsys
/
from.rdm
< prev
next >
Wrap
Text File
|
1996-05-20
|
2KB
|
75 lines
Short: Best foreach type command ever
Author: Thomas.Radtke@rz.uni-osnabrueck.de
Uploader: Thomas.Radtke@rz.uni-osnabrueck.de
Type: util/cli
'from' is a non-standart, AmigaDOS friendly 'foreach' implementation.
The from command will execute a specified command for every line of a given
input source (file or stdin). 'from' is freeware (C) Thomas Radtke 1996.
C Source code included.
Syntax: from <list|-> <command> [args]
'-' is treated as stdin.
The following _local_ variables will be generated for each line of list:
0 command name
i where i=1..n and n is the number of words in the line
row actual row in the list (Note: first line is 0, not 1)
You can access the variables in the usual way, i.e. $row,$0,$1,..
Examples:
(1) dircmp2 -i -p -c bin: c: | from - delete $1
Deletes all identical files from directory bin. Hey, don't
try to automatically remove things, this is only an example, ok ?
(unless you have a reliable undel program ;)
(2) from mass_output move $1 waste:mass.$row
moves all files from the mass_output list to waste: as
mass.0, mass.1,... (this could be temporary files from somewhere)
(3) from mass_output type $1 >>join_them_together
mass-join operation of files from the list
Although 'from' is superior to 'foreach', it doesn't allow any internal
filtering of the input lines (e.g. wildcards, refer to -x,-X options in
dircmp2). I think this is obsolete here, since filtering can be done through
'edit' or 'sed' in a better way.
Reference:
dircmp2
-------
The dircmp2 command can be found on Aminet as dircmp2a2.lha (also on CD11?).
An older UN*X version exist in dircmp2.lha.
foreach
-------
There is at least one other foreach type command on Aminet, but is is
buggy and has invalidated my HD.
move
----
The move command can be found in various versions on Aminet
(imo best bet is move110.lha, also on Set1,CD A)
sed
---
Beside the GNU binutils, you will find 'sed' on Aminet as ixemul-free
port.
Implementation notes:
---------------------
(i) The binary was compiled from from.c with the Aminet version of
gcc 2.7.0 and libnix v1.0 static library.
(ii) I am using 'from' successfully on my A4000/EC30/882/2+4/3.0.
You must have at least the dos library V36 (2.0?) to get this to work.
You will not enjoy the processing speed with a M68k CPU.
If you like this program, drop me a letter.
Thomas